<?php

$action = $_REQUEST["action"];

switch($action)
{
case 'get_msg':

  $last_msg_time = $_REQUEST["last_msg_time"];

  $mysql = new SaeMysql();
  if($last_msg_time)
  {
    $sql = "SELECT * FROM `message` WHERE UNIX_TIMESTAMP(time)*1000 > " . $last_msg_time . ' ORDER BY time desc';
  }
  else
  {
    $sql = "SELECT * FROM `message` ORDER BY time desc";
  }

  $data = $mysql->getData( $sql );

  echo json_encode($data);

  $mysql->closeDb();

  break;
}

?>
